/*
 * devicemgmt.wsdl web service operations
 * implemention
 *
 */

#include "../soapH.h"
#include "../onvif.h"
#include "device_service.h"

//the device information ,that should be stored in files.
//here use static-variables to record these information.
static char *host_name = "www.zmvideo.com";

int get_backup_filecont(unsigned char *ptr, const char *filename, int size)
{
	int fd = -1;
	int nread = 0;
	int ret = 0; 

	if(ptr == NULL || filename == NULL || size <= 0)
	{
		DBG("invalid params!\n");
		return -1;
	}

	if(!access(filename, R_OK))
	{
		DBG("%s read error!\n", filename);
		return -1;
	}

	fd = open(filename, O_RDONLY);
	if(fd < 0) return -1;
	while(nread < size)
	{
		ret = read(fd, ptr, size);
		if(ret > 0) nread += ret;
		else if(ret < 0 && errno == EINTR) continue;
		else if(ret == 0) break;
		else 
		{
			DBG("has read %d\n",nread);
			return -1;
		}
	}

	return 0;
}

static int get_analytics_caps(struct soap *soap, struct tt__AnalyticsCapabilities *analytics)
{
	if(analytics == NULL)
	{
		DBG("analytics is invalid.\n");
		return -1;
	}
	// to implement ...
	analytics->XAddr = (char *)soap_malloc(soap,sizeof(char)*XADDR_LEN);
	strcpy(analytics->XAddr, get_xaddrs());

	analytics->RuleSupport = FALSE;
	analytics->AnalyticsModuleSupport = FALSE;

	analytics->__size = 0;
	analytics->__any = NULL;
	analytics->__anyAttribute = NULL;
	return 0;
}

static int get_device_caps(struct soap *soap, struct tt__DeviceCapabilities *device)
{	
	if(device == NULL)
	{
		DBG("device is invalid.\n");
		return -1;
	}
	/*基础设置，很必须*/
	device->XAddr = (char *)soap_malloc(soap, sizeof(char) * XADDR_LEN);
	strcpy(device->XAddr, get_xaddrs());	

	/*必要部分*/
	device->Network = (struct tt__NetworkCapabilities*)soap_malloc(soap, sizeof(struct tt__NetworkCapabilities));
	device->Network->IPFilter = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->ZeroConfiguration = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->IPVersion6 = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->DynDNS = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->Extension = (struct tt__NetworkCapabilitiesExtension*)soap_malloc(soap, sizeof(struct tt__NetworkCapabilitiesExtension));
	device->Network->Extension->Dot11Configuration = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean)); 
		
	*device->Network->IPFilter = dev_network_caps[NET_CAP_IPFILTER];	
	*device->Network->ZeroConfiguration = dev_network_caps[NET_CAP_ZEROCONFG];
	*device->Network->IPVersion6 = dev_network_caps[NET_CAP_IPV6];
	*device->Network->DynDNS = dev_network_caps[NET_CAP_DDNS];	
	*device->Network->Extension->Dot11Configuration = dev_network_caps[NET_CAP_DOT11CONFG]; 
	device->Network->Extension->Extension = NULL;
	device->Network->Extension->__size= 0;
	device->Network->Extension->__any = NULL;

	device->System=(struct tt__SystemCapabilities*)soap_malloc(soap,sizeof(struct tt__SystemCapabilities));
	device->System->SupportedVersions = (struct tt__OnvifVersion*)soap_malloc(soap, sizeof(struct tt__OnvifVersion));
	device->System->Extension = (struct tt__SystemCapabilitiesExtension*)soap_malloc(soap, sizeof(struct tt__SystemCapabilitiesExtension));
	device->System->Extension->HttpSystemBackup = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->Extension->HttpFirmwareUpgrade = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->Extension->HttpSystemLogging = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->Extension->HttpSupportInformation = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->DiscoveryResolve = dev_system_caps[SYS_CAP_DRES];
	device->System->DiscoveryBye = dev_system_caps[SYS_CAP_DBYE];
	device->System->RemoteDiscovery = dev_system_caps[SYS_CAP_RD];
	device->System->SystemBackup = dev_system_caps[SYS_CAP_BACKUP];
	device->System->SystemLogging = dev_system_caps[SYS_CAP_LOG];
	device->System->FirmwareUpgrade = dev_system_caps[SYS_CAP_UPGRADE];	
	device->System->__sizeSupportedVersions = 1;
	device->System->SupportedVersions->Major = dev_sup_version[0];
	device->System->SupportedVersions->Minor = dev_sup_version[1];
	*device->System->Extension->HttpSystemBackup = dev_system_caps[SYS_CAP_HTTPBACK];
	*device->System->Extension->HttpFirmwareUpgrade = dev_system_caps[SYS_CAP_HTTPUP];
	*device->System->Extension->HttpSystemLogging = dev_system_caps[SYS_CAP_HTTPLOG];
	*device->System->Extension->HttpSupportInformation = dev_system_caps[SYS_CAP_HTTPINFO];
	device->System->Extension->Extension = NULL;
	device->System->Extension->__size = 0;
	device->System->Extension->__any = NULL;

	device->IO = NULL;
	
	device->Security = (struct tt__SecurityCapabilities*)soap_malloc(soap, sizeof(struct tt__SecurityCapabilities));
	device->Security->TLS1_x002e1 = dev_security_caps[SEC_CAP_TLSE0];	
	device->Security->TLS1_x002e2 = dev_security_caps[SEC_CAP_TLSE1];	
	device->Security->OnboardKeyGeneration = dev_security_caps[SEC_CAP_OKG];
	device->Security->AccessPolicyConfig = dev_security_caps[SEC_CAP_APC];
	device->Security->X_x002e509Token = dev_security_caps[SEC_CAP_X509T];
	device->Security->SAMLToken = dev_security_caps[SEC_CAP_SAMLT];	
	device->Security->KerberosToken = dev_security_caps[SEC_CAP_KERBT];
	device->Security->RELToken = dev_security_caps[SEC_CAP_RELT];	
	device->Security->Extension = NULL;
	device->Security->__size = 0;
	device->Security->__any = NULL;
	device->Security->__anyAttribute = NULL;

	device->Extension = NULL;

	return 0;
}

static int get_events_caps(struct soap *soap, struct tt__EventCapabilities *event)
{
	if(event == NULL)
	{
		DBG("event is invalid.\n");
		return -1;
	}
	// to implement ...
	// required 
	event->XAddr = (char*)soap_malloc(soap,sizeof(char)*XADDR_LEN);
	strcpy(event->XAddr,get_xaddrs());

	event->WSSubscriptionPolicySupport = events_caps[EVENT_CAP_SPS];
	event->WSPullPointSupport = events_caps[EVENT_CAP_PPS];
	event->WSPausableSubscriptionManagerInterfaceSupport = events_caps[EVENT_CAP_PSMIS];

	//optional
	event->__size = 0;
	event->__any = NULL;
	event->__anyAttribute = NULL;

	return 0;
}

static int get_imaging_caps(struct soap *soap, struct tt__ImagingCapabilities *image)
{
	if(image == NULL)
	{
		DBG("image is invalid.\n");
		return -1;
	}
	// to implement ...
	// required
	image->XAddr = (char*)soap_malloc(soap,sizeof(char)*XADDR_LEN);
	strcpy(image->XAddr,get_xaddrs());
#if 0
	DBG("image->XAddr:%p\n",image->XAddr);
	DBG("xaddrs:%s\n",get_xaddrs());
#endif

	image->__anyAttribute = NULL;
	return 0;
}

static int get_media_caps(struct soap *soap, struct tt__MediaCapabilities *media)
{
	if(media == NULL)
	{
		DBG("media is invalid.\n");
		return -1;
	}
	//想要对接RTSP视频，必须设置Media
	media->XAddr = (char *)soap_malloc(soap, sizeof(char) * XADDR_LEN);
	strcpy(media->XAddr, get_xaddrs());

	media->StreamingCapabilities = (struct tt__RealTimeStreamingCapabilities*)soap_malloc(soap, sizeof(struct tt__RealTimeStreamingCapabilities));
	media->StreamingCapabilities->RTPMulticast = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));	
	media->StreamingCapabilities->RTP_USCORETCP = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	media->StreamingCapabilities->RTP_USCORERTSP_USCORETCP = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));

	*media->StreamingCapabilities->RTPMulticast = media_caps[RTP_MULTICAST];	
	*media->StreamingCapabilities->RTP_USCORETCP = media_caps[RTP_TCP];	
	*media->StreamingCapabilities->RTP_USCORERTSP_USCORETCP = media_caps[RTP_RTSP_TCP];	
	media->StreamingCapabilities->Extension = NULL;
	
	media->Extension = NULL;
	media->__size = 0;
	media->__any = NULL;
	media->__anyAttribute = NULL;
	
	return 0;
}

static int get_ptz_caps(struct soap *soap, struct tt__PTZCapabilities *ptz)
{
	if(ptz == NULL)
	{
		DBG("ptz is invalid.\n");
		return -1;
	}
	// to implement ...
	// required
	ptz->XAddr = (char*)soap_malloc(soap,sizeof(char)*XADDR_LEN);
	strcpy(ptz->XAddr,get_xaddrs());

	ptz->__size = 0;
	ptz->__any = NULL;
	ptz->__anyAttribute = NULL;
	return 0;
}

static int get_extension_caps(struct soap *soap, struct tt__CapabilitiesExtension *extension)
{
	if(extension == NULL)
	{
		DBG("extension is invalid.\n");
		return -1;
	}

	extension->DeviceIO = (struct tt__DeviceIOCapabilities*)soap_malloc(soap, sizeof(struct tt__DeviceIOCapabilities));
	extension->DeviceIO->XAddr = (char *)soap_malloc(soap, sizeof(char) * XADDR_LEN);
	strcpy(extension->DeviceIO->XAddr,get_xaddrs());

	//下面的重要，这里只实现视频流，需要设置VideoSources
	extension->DeviceIO->VideoSources = deviceio_caps[IO_CAP_VS];//number of source
	extension->DeviceIO->VideoOutputs = deviceio_caps[IO_CAP_VO];
	extension->DeviceIO->AudioSources = deviceio_caps[IO_CAP_AS];
	extension->DeviceIO->AudioOutputs = deviceio_caps[IO_CAP_AO];
	extension->DeviceIO->RelayOutputs = deviceio_caps[IO_CAP_RO];
	extension->DeviceIO->__size = 0;
	extension->DeviceIO->__any = NULL;
	
	extension->Display = NULL;
	extension->Recording = NULL;
	extension->Search = NULL;
	extension->Replay = NULL;
	extension->Receiver = NULL;
	extension->AnalyticsDevice = NULL;
	extension->Extensions = NULL;
	extension->__size = 0;
	extension->__any = NULL;

	return 0;
}

int get_deviceservice_cap(struct soap *soap, struct tds__DeviceServiceCapabilities *device)
{
	if(soap == NULL || device == NULL)
	{
		DBG("invalid params!\n");
		return -1;
	}
	
	device->__size = 0;
	device->__any = NULL;

	// network capabilities
	device->Network = (struct tds__NetworkCapabilities *)soap_malloc(soap, sizeof(struct tds__NetworkCapabilities));
	device->Network->IPFilter = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->ZeroConfiguration = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->IPVersion6 = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Network->DynDNS = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean));	
	device->Network->Dot11Configuration = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean)); 
	device->Network->HostnameFromDHCP = (enum xsd__boolean *)soap_malloc(soap, sizeof(enum xsd__boolean)); 
	device->Network->NTP = (int *)soap_malloc(soap, sizeof(int)); 
	device->Network->__anyAttribute = NULL;

	*device->Network->IPFilter = dev_network_caps[NET_CAP_IPFILTER];
	*device->Network->ZeroConfiguration = dev_network_caps[NET_CAP_ZEROCONFG];
	*device->Network->IPVersion6 = dev_network_caps[NET_CAP_IPV6];
	*device->Network->DynDNS = dev_network_caps[NET_CAP_DDNS];
	*device->Network->Dot11Configuration = dev_network_caps[NET_CAP_DOT11CONFG];
	*device->Network->HostnameFromDHCP = dev_network_caps[NET_CAP_HOSTFD];
	*device->Network->NTP = dev_network_caps[NET_CAP_NTP];

	// security capabilities
	device->Security = (struct tds__SecurityCapabilities *)soap_malloc(soap, sizeof(struct tds__SecurityCapabilities));
	device->Security->TLS1_x002e0 = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->TLS1_x002e1 = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->TLS1_x002e2 = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->OnboardKeyGeneration = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->AccessPolicyConfig = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->Dot1X = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->RemoteUserHandling = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->X_x002e509Token = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->SAMLToken = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->KerberosToken = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->UsernameToken = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->HttpDigest = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->Security->RELToken = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));

	*device->Security->TLS1_x002e0 = dev_security_caps[SEC_CAP_TLSE0];
	*device->Security->TLS1_x002e1 = dev_security_caps[SEC_CAP_TLSE1];
	*device->Security->TLS1_x002e2 = dev_security_caps[SEC_CAP_TLSE2];
	*device->Security->OnboardKeyGeneration = dev_security_caps[SEC_CAP_OKG];
	*device->Security->AccessPolicyConfig = dev_security_caps[SEC_CAP_APC];
	*device->Security->Dot1X = dev_security_caps[SEC_CAP_DOT1X];
	*device->Security->RemoteUserHandling = dev_security_caps[SEC_CAP_RUH];
	*device->Security->X_x002e509Token = dev_security_caps[SEC_CAP_X509T];
	*device->Security->SAMLToken = dev_security_caps[SEC_CAP_SAMLT];
	*device->Security->KerberosToken = dev_security_caps[SEC_CAP_KERBT];
	*device->Security->UsernameToken = dev_security_caps[SEC_CAP_USERT];
	*device->Security->HttpDigest = dev_security_caps[SEC_CAP_HTTPDIG];
	*device->Security->RELToken = dev_security_caps[SEC_CAP_RELT];
	device->Security->SupportedEAPMethods = NULL;

	// system capabilities
	device->System = (struct tds__SystemCapabilities *)soap_malloc(soap, sizeof(struct tds__SystemCapabilities));
	device->System->DiscoveryResolve = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->DiscoveryBye = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->RemoteDiscovery = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->SystemBackup = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->SystemLogging = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->FirmwareUpgrade = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->HttpFirmwareUpgrade = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->HttpSystemBackup = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->HttpSystemLogging = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));
	device->System->HttpSupportInformation = (enum xsd__boolean*)soap_malloc(soap, sizeof(enum xsd__boolean));

	*device->System->DiscoveryResolve = dev_system_caps[SYS_CAP_DRES];
	*device->System->DiscoveryBye = dev_system_caps[SYS_CAP_DBYE];
	*device->System->RemoteDiscovery = dev_system_caps[SYS_CAP_RD];
	*device->System->SystemBackup = dev_system_caps[SYS_CAP_BACKUP];
	*device->System->SystemLogging = dev_system_caps[SYS_CAP_LOG];
	*device->System->FirmwareUpgrade = dev_system_caps[SYS_CAP_UPGRADE];
	*device->System->HttpFirmwareUpgrade = dev_system_caps[SYS_CAP_HTTPUP];
	*device->System->HttpSystemBackup = dev_system_caps[SYS_CAP_HTTPBACK];
	*device->System->HttpSystemLogging = dev_system_caps[SYS_CAP_HTTPLOG];
	*device->System->HttpSupportInformation = dev_system_caps[SYS_CAP_HTTPINFO];

	return 0;
}

//=======================================================================================================//
/** Auto-test server operation __tds__GetServices */
int __tds__GetServices(struct soap *soap, struct _tds__GetServices *tds__GetServices, struct _tds__GetServicesResponse *tds__GetServicesResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	int inc_cap = tds__GetServices->IncludeCapability;
	int size, i;
	char *pcap = NULL;
	
	tds__GetServicesResponse->__sizeService = size = dev_services_num;
	tds__GetServicesResponse->Service = (struct tds__Service *)soap_malloc(soap, sizeof(struct tds__Service)*size);

	struct tds__Service *p = tds__GetServicesResponse->Service;
	for(i=0;i<size&&p;i++)
	{
		p[i].Namespace = (char *)soap_malloc(soap, sizeof(char)*XADDR_LEN);
		p[i].XAddr = (char *)soap_malloc(soap, sizeof(char)*XADDR_LEN);
		p[i].Version = (struct tt__OnvifVersion *)soap_malloc(soap, sizeof(struct tt__OnvifVersion));
		strncpy(p[i].XAddr, get_xaddrs(), XADDR_LEN);
		p[i].Version->Major = dev_sup_version[0];
		p[i].Version->Minor = dev_sup_version[1];
		p[i].__size = 0;
		p[i].__any = NULL;
		p[i].__anyAttribute = NULL;
		p[i].Capabilities = NULL; // optional element

		if(inc_cap)
		{
			p[i].Capabilities = (struct _tds__Service_Capabilities *)soap_malloc(soap, sizeof(struct _tds__Service_Capabilities));
			pcap = p[i].Capabilities->__any = NULL;
		}

		if(!strcasecmp(dev_services[i], "device"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/device/wsdl");	
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tds__DeviceServiceCapabilities));
				get_deviceservice_cap(soap,(struct tds__DeviceServiceCapabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"analytics"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver20/analytics/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tan__Capabilities));
				get_analyticservice_cap(soap, (struct tan__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"event"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/events/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tev__Capabilities));
				get_eventservice_cap(soap, (struct tev__Capabilities*)pcap);
			}
		}

		else if(!strcasecmp(dev_services[i],"image"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver20/imaging/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct timg__Capabilities));
				get_imageservice_cap(soap, (struct timg__Capabilities*)pcap);
			}
		}

		else if(!strcasecmp(dev_services[i],"display"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/display/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tls__Capabilities));
				get_displayservice_cap(soap, (struct tls__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"deviceio"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/deviceIO/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tmd__Capabilities));
				get_deviceioservice_cap(soap, (struct tmd__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"ptz"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver20/ptz/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tptz__Capabilities));
				get_ptzservice_cap(soap, (struct tptz__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"recording"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/recording/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct trc__Capabilities));
				get_recordservice_cap(soap, (struct trc__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"replay"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/replay/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct trp__Capabilities));
				get_replayservice_cap(soap, (struct trp__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"media"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/media/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct trt__Capabilities));
				get_mediaservice_cap(soap, (struct trt__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"receiver"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/receiver/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct trv__Capabilities));
				get_receiverservice_cap(soap, (struct trv__Capabilities*)pcap);
			}
		}
		else if(!strcasecmp(dev_services[i],"search"))
		{
			strcpy(p[i].Namespace, "http://www.onvif.org/ver10/search/wsdl");
			if(inc_cap)
			{
				pcap = (char*)soap_malloc(soap, sizeof(struct tse__Capabilities));
				get_searchservice_cap(soap, (struct tse__Capabilities*)pcap);
			}
		}
	}

	return SOAP_OK;
}


/** Auto-test server operation __tds__GetServiceCapabilities */
int __tds__GetServiceCapabilities(struct soap *soap, struct _tds__GetServiceCapabilities *tds__GetServiceCapabilities, struct _tds__GetServiceCapabilitiesResponse *tds__GetServiceCapabilitiesResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	tds__GetServiceCapabilitiesResponse->Capabilities = (struct tds__DeviceServiceCapabilities *)soap_malloc(soap, sizeof(struct tds__DeviceServiceCapabilities));
	get_deviceservice_cap(soap, tds__GetServiceCapabilitiesResponse->Capabilities);

	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDeviceInformation */
int __tds__GetDeviceInformation(struct soap *soap, struct _tds__GetDeviceInformation *tds__GetDeviceInformation, struct _tds__GetDeviceInformationResponse *tds__GetDeviceInformationResponse)
{	
	/* Return incomplete response with default data values */
	tds__GetDeviceInformationResponse->Manufacturer = (char *)soap_malloc(soap, sizeof(char) * INFO_LEN);
	tds__GetDeviceInformationResponse->Model = (char *)soap_malloc(soap, sizeof(char) * INFO_LEN);
	tds__GetDeviceInformationResponse->FirmwareVersion = (char *)soap_malloc(soap, sizeof(char) * INFO_LEN);
	tds__GetDeviceInformationResponse->SerialNumber = (char *)soap_malloc(soap, sizeof(char) * INFO_LEN);
	tds__GetDeviceInformationResponse->HardwareId = (char *)soap_malloc(soap, sizeof(char) * INFO_LEN);
	
	strcpy(tds__GetDeviceInformationResponse->Manufacturer,device_info[DEV_INFO_MANU]);	
	strcpy(tds__GetDeviceInformationResponse->Model,device_info[DEV_INFO_MODEL]);	
	strcpy(tds__GetDeviceInformationResponse->FirmwareVersion,device_info[DEV_INFO_FMVER]);	
	strcpy(tds__GetDeviceInformationResponse->SerialNumber,device_info[DEV_INFO_SN]);	
	strcpy(tds__GetDeviceInformationResponse->HardwareId,device_info[DEV_INFO_HWID]);	

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetSystemDateAndTime */
int __tds__SetSystemDateAndTime(struct soap *soap, struct _tds__SetSystemDateAndTime *tds__SetSystemDateAndTime, struct _tds__SetSystemDateAndTimeResponse *tds__SetSystemDateAndTimeResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetSystemDateAndTime */
int __tds__GetSystemDateAndTime(struct soap *soap, struct _tds__GetSystemDateAndTime *tds__GetSystemDateAndTime, struct _tds__GetSystemDateAndTimeResponse *tds__GetSystemDateAndTimeResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetSystemFactoryDefault */
int __tds__SetSystemFactoryDefault(struct soap *soap, struct _tds__SetSystemFactoryDefault *tds__SetSystemFactoryDefault, struct _tds__SetSystemFactoryDefaultResponse *tds__SetSystemFactoryDefaultResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__UpgradeSystemFirmware */
int __tds__UpgradeSystemFirmware(struct soap *soap, struct _tds__UpgradeSystemFirmware *tds__UpgradeSystemFirmware, struct _tds__UpgradeSystemFirmwareResponse *tds__UpgradeSystemFirmwareResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SystemReboot */
int __tds__SystemReboot(struct soap *soap, struct _tds__SystemReboot *tds__SystemReboot, struct _tds__SystemRebootResponse *tds__SystemRebootResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}

/** Auto-test server operation __tds__RestoreSystem */
int __tds__RestoreSystem(struct soap *soap, struct _tds__RestoreSystem *tds__RestoreSystem, struct _tds__RestoreSystemResponse *tds__RestoreSystemResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetSystemBackup */
int __tds__GetSystemBackup(struct soap *soap, struct _tds__GetSystemBackup *tds__GetSystemBackup, struct _tds__GetSystemBackupResponse *tds__GetSystemBackupResponse)
{	
	/* Return incomplete response with default data values */
	int i, size;

	tds__GetSystemBackupResponse->__sizeBackupFiles = size = atoi(system_backup_files[SYS_BACK_FNUM]);
	tds__GetSystemBackupResponse->BackupFiles = (struct tt__BackupFile *)soap_malloc(soap, sizeof(struct tt__BackupFile)*size);
	int cnt_1 = 0;
	int cnt_2 = 0;
	char *p = system_backup_files[SYS_BACK_FNAME];
	char *q = system_backup_files[SYS_BACK_FSIZE];
	for(i = 0;i < size;i++)
	{
		p += cnt_1;
		q += cnt_2;
		tds__GetSystemBackupResponse->BackupFiles[i].Name = (char *)soap_malloc(soap,sizeof(char) * INFO_LEN);
		tds__GetSystemBackupResponse->BackupFiles[i].Data = (struct tt__AttachmentData *)soap_malloc(soap,sizeof(struct tt__AttachmentData)); 
		tds__GetSystemBackupResponse->BackupFiles[i].Data->xmime__contentType = (char *)soap_malloc(soap,sizeof(char)*INFO_LEN);
		//tds__GetSystemBackupResponse->BackupFiles->Data->xop__Include.id = (char *)soap_malloc(soap,sizeof(char)*INFO_LEN);

		sscanf(p,"%[^;];%n", tds__GetSystemBackupResponse->BackupFiles[i].Name, &cnt_1);
		sscanf(q,"%d;%n", &size, &cnt_2);

		tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.__ptr = (unsigned char *)soap_malloc(soap,sizeof(unsigned char)*size);
		tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.__size = size;
		strcpy(tds__GetSystemBackupResponse->BackupFiles[i].Data->xmime__contentType, system_backup_files[SYS_BACK_XMIME]);         //option 
		// read backup file to __ptr.
		get_backup_filecont(tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.__ptr, 
				tds__GetSystemBackupResponse->BackupFiles[i].Name, size);

		tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.id = NULL;          //option
		tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.type = NULL;        //option
		tds__GetSystemBackupResponse->BackupFiles[i].Data->xop__Include.options = NULL;     //option
	}

	return SOAP_OK;
}


/** Auto-test server operation __tds__GetSystemLog */
int __tds__GetSystemLog(struct soap *soap, struct _tds__GetSystemLog *tds__GetSystemLog, struct _tds__GetSystemLogResponse *tds__GetSystemLogResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetSystemSupportInformation */
int __tds__GetSystemSupportInformation(struct soap *soap, struct _tds__GetSystemSupportInformation *tds__GetSystemSupportInformation, struct _tds__GetSystemSupportInformationResponse *tds__GetSystemSupportInformationResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetScopes */
int __tds__GetScopes(struct soap *soap, struct _tds__GetScopes *tds__GetScopes, struct _tds__GetScopesResponse *tds__GetScopesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetScopes */
int __tds__SetScopes(struct soap *soap, struct _tds__SetScopes *tds__SetScopes, struct _tds__SetScopesResponse *tds__SetScopesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__AddScopes */
int __tds__AddScopes(struct soap *soap, struct _tds__AddScopes *tds__AddScopes, struct _tds__AddScopesResponse *tds__AddScopesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__RemoveScopes */
int __tds__RemoveScopes(struct soap *soap, struct _tds__RemoveScopes *tds__RemoveScopes, struct _tds__RemoveScopesResponse *tds__RemoveScopesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDiscoveryMode */
int __tds__GetDiscoveryMode(struct soap *soap, struct _tds__GetDiscoveryMode *tds__GetDiscoveryMode, struct _tds__GetDiscoveryModeResponse *tds__GetDiscoveryModeResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetDiscoveryMode */
int __tds__SetDiscoveryMode(struct soap *soap, struct _tds__SetDiscoveryMode *tds__SetDiscoveryMode, struct _tds__SetDiscoveryModeResponse *tds__SetDiscoveryModeResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetRemoteDiscoveryMode */
int __tds__GetRemoteDiscoveryMode(struct soap *soap, struct _tds__GetRemoteDiscoveryMode *tds__GetRemoteDiscoveryMode, struct _tds__GetRemoteDiscoveryModeResponse *tds__GetRemoteDiscoveryModeResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetRemoteDiscoveryMode */
int __tds__SetRemoteDiscoveryMode(struct soap *soap, struct _tds__SetRemoteDiscoveryMode *tds__SetRemoteDiscoveryMode, struct _tds__SetRemoteDiscoveryModeResponse *tds__SetRemoteDiscoveryModeResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDPAddresses */
int __tds__GetDPAddresses(struct soap *soap, struct _tds__GetDPAddresses *tds__GetDPAddresses, struct _tds__GetDPAddressesResponse *tds__GetDPAddressesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetEndpointReference */
int __tds__GetEndpointReference(struct soap *soap, struct _tds__GetEndpointReference *tds__GetEndpointReference, struct _tds__GetEndpointReferenceResponse *tds__GetEndpointReferenceResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetRemoteUser */
int __tds__GetRemoteUser(struct soap *soap, struct _tds__GetRemoteUser *tds__GetRemoteUser, struct _tds__GetRemoteUserResponse *tds__GetRemoteUserResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetRemoteUser */
int __tds__SetRemoteUser(struct soap *soap, struct _tds__SetRemoteUser *tds__SetRemoteUser, struct _tds__SetRemoteUserResponse *tds__SetRemoteUserResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetUsers */
int __tds__GetUsers(struct soap *soap, struct _tds__GetUsers *tds__GetUsers, struct _tds__GetUsersResponse *tds__GetUsersResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__CreateUsers */
int __tds__CreateUsers(struct soap *soap, struct _tds__CreateUsers *tds__CreateUsers, struct _tds__CreateUsersResponse *tds__CreateUsersResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__DeleteUsers */
int __tds__DeleteUsers(struct soap *soap, struct _tds__DeleteUsers *tds__DeleteUsers, struct _tds__DeleteUsersResponse *tds__DeleteUsersResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetUser */
int __tds__SetUser(struct soap *soap, struct _tds__SetUser *tds__SetUser, struct _tds__SetUserResponse *tds__SetUserResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetWsdlUrl */
int __tds__GetWsdlUrl(struct soap *soap, struct _tds__GetWsdlUrl *tds__GetWsdlUrl, struct _tds__GetWsdlUrlResponse *tds__GetWsdlUrlResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	tds__GetWsdlUrlResponse->WsdlUrl = (char *)soap_malloc(soap, sizeof(char)*XADDR_LEN);
	strcpy(tds__GetWsdlUrlResponse->WsdlUrl, "http://www.onvif.org/Documents/Specifications.aspx");

	return SOAP_OK;
}


/** Auto-test server operation __tds__GetCapabilities */
int __tds__GetCapabilities(struct soap *soap, struct _tds__GetCapabilities *tds__GetCapabilities, struct _tds__GetCapabilitiesResponse *tds__GetCapabilitiesResponse)
{	
	/* Return incomplete response with default data values */
	
	DBG("__tds__GetCapabilities\n");
	int category;

	tds__GetCapabilitiesResponse->Capabilities = (struct tt__Capabilities*)soap_malloc(soap, sizeof(struct tt__Capabilities));
	tds__GetCapabilitiesResponse->Capabilities->Analytics = NULL;
	tds__GetCapabilitiesResponse->Capabilities->Device = NULL;
	tds__GetCapabilitiesResponse->Capabilities->Events = NULL;
	tds__GetCapabilitiesResponse->Capabilities->Imaging = NULL;
	tds__GetCapabilitiesResponse->Capabilities->Media = NULL;
	tds__GetCapabilitiesResponse->Capabilities->PTZ = NULL;
	tds__GetCapabilitiesResponse->Capabilities->Extension= NULL;

	if(tds__GetCapabilities->Category == NULL)
	{
		category = tt__CapabilityCategory__All;
	}
	else
	{
		category = *tds__GetCapabilities->Category;
	}
	//DBG("category = %d\n",category);
	if(category == tt__CapabilityCategory__All)
	{
		// get all caps
		tds__GetCapabilitiesResponse->Capabilities->Analytics = 
		(struct tt__AnalyticsCapabilities*)soap_malloc(soap, sizeof(struct tt__AnalyticsCapabilities));
		get_analytics_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Analytics);
		tds__GetCapabilitiesResponse->Capabilities->Device = 
			(struct tt__DeviceCapabilities*)soap_malloc(soap, sizeof(struct tt__DeviceCapabilities));
		get_device_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Device);
#if 1
		tds__GetCapabilitiesResponse->Capabilities->Events = 
			(struct tt__EventCapabilities*)soap_malloc(soap, sizeof(struct tt__EventCapabilities));
		get_events_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Events);
#endif
		tds__GetCapabilitiesResponse->Capabilities->Imaging = 
			(struct tt__ImagingCapabilities*)soap_malloc(soap, sizeof(struct tt__ImagingCapabilities));
		get_imaging_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Imaging);
		tds__GetCapabilitiesResponse->Capabilities->Media = 
			(struct tt__MediaCapabilities*)soap_malloc(soap, sizeof(struct tt__MediaCapabilities));
		get_media_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Media);
		tds__GetCapabilitiesResponse->Capabilities->PTZ = 
			(struct tt__PTZCapabilities*)soap_malloc(soap, sizeof(struct tt__PTZCapabilities));
		get_ptz_caps(soap,tds__GetCapabilitiesResponse->Capabilities->PTZ);
	}
	else
	{
		switch(category)
		{
			case tt__CapabilityCategory__Analytics:
				tds__GetCapabilitiesResponse->Capabilities->Analytics = 
				(struct tt__AnalyticsCapabilities*)soap_malloc(soap, sizeof(struct tt__AnalyticsCapabilities));
				get_analytics_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Analytics);
				break;
			case tt__CapabilityCategory__Device:
				tds__GetCapabilitiesResponse->Capabilities->Device = 
					(struct tt__DeviceCapabilities*)soap_malloc(soap, sizeof(struct tt__DeviceCapabilities));
				get_device_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Device);
				break;
			case tt__CapabilityCategory__Events:
				tds__GetCapabilitiesResponse->Capabilities->Events = 
					(struct tt__EventCapabilities*)soap_malloc(soap, sizeof(struct tt__EventCapabilities));
				get_events_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Events);
				break;
			case tt__CapabilityCategory__Imaging:
				tds__GetCapabilitiesResponse->Capabilities->Imaging = 
					(struct tt__ImagingCapabilities*)soap_malloc(soap, sizeof(struct tt__ImagingCapabilities));
				get_imaging_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Imaging);
				break;
			case tt__CapabilityCategory__Media:
				tds__GetCapabilitiesResponse->Capabilities->Media = 
					(struct tt__MediaCapabilities*)soap_malloc(soap, sizeof(struct tt__MediaCapabilities));
				get_media_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Media);
				break;
			case tt__CapabilityCategory__PTZ:
				tds__GetCapabilitiesResponse->Capabilities->PTZ = 
					(struct tt__PTZCapabilities*)soap_malloc(soap, sizeof(struct tt__PTZCapabilities));
				get_ptz_caps(soap,tds__GetCapabilitiesResponse->Capabilities->PTZ);
				break;
			default:
				// category error, return soap fault.
				// fault code -- subcode ...
				DBG("category error.\n");
				return SOAP_OK;
		}
	}
	tds__GetCapabilitiesResponse->Capabilities->Extension = 
		(struct tt__CapabilitiesExtension*)soap_malloc(soap, sizeof(struct tt__CapabilitiesExtension));
	get_extension_caps(soap,tds__GetCapabilitiesResponse->Capabilities->Extension);

	//DBG("getcapabilities end.\n");
	return SOAP_OK;
}

/** Auto-test server operation __tds__SetDPAddresses */
int __tds__SetDPAddresses(struct soap *soap, struct _tds__SetDPAddresses *tds__SetDPAddresses, struct _tds__SetDPAddressesResponse *tds__SetDPAddressesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetHostname */
int __tds__GetHostname(struct soap *soap, struct _tds__GetHostname *tds__GetHostname, struct _tds__GetHostnameResponse *tds__GetHostnameResponse)
{	
	/* Return incomplete response with default data values */
	DBG("__tds__GetHostname\n");
	tds__GetHostnameResponse->HostnameInformation = (struct tt__HostnameInformation*)soap_malloc(soap,sizeof(struct tt__HostnameInformation));
	tds__GetHostnameResponse->HostnameInformation->FromDHCP = 0; //not from DHCP
	tds__GetHostnameResponse->HostnameInformation->Name = (char*)soap_malloc(soap,100);
	strcpy(tds__GetHostnameResponse->HostnameInformation->Name,host_name);
	
	tds__GetHostnameResponse->HostnameInformation->Extension = (struct tt__HostnameInformationExtension*)soap_malloc(soap,sizeof(struct tt__HostnameInformationExtension ));
	tds__GetHostnameResponse->HostnameInformation->Extension->__size = 0;
	tds__GetHostnameResponse->HostnameInformation->Extension->__any= NULL;
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetHostname */
int __tds__SetHostname(struct soap *soap, struct _tds__SetHostname *tds__SetHostname, struct _tds__SetHostnameResponse *tds__SetHostnameResponse)
{
	INFO(stderr);
	save_configs("Hostname",(void *)tds__SetHostname->Name, TYPE_STR);
	
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetHostnameFromDHCP */
int __tds__SetHostnameFromDHCP(struct soap *soap, struct _tds__SetHostnameFromDHCP *tds__SetHostnameFromDHCP, struct _tds__SetHostnameFromDHCPResponse *tds__SetHostnameFromDHCPResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);
	char p[10];

	sprintf(p,"%d",tds__SetHostnameFromDHCP->FromDHCP);
	save_configs("HostnameFromDHCP",(void *)p, TYPE_STR);
	
	tds__SetHostnameFromDHCPResponse->RebootNeeded = 0;
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDNS */
int __tds__GetDNS(struct soap *soap, struct _tds__GetDNS *tds__GetDNS, struct _tds__GetDNSResponse *tds__GetDNSResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	tds__GetDNSResponse->DNSInformation = (struct tt__DNSInformation *)soap_malloc(soap,sizeof(struct tt__DNSInformation ));
	tds__GetDNSResponse->DNSInformation->FromDHCP = FALSE;
	tds__GetDNSResponse->DNSInformation->__sizeSearchDomain = 0;
	tds__GetDNSResponse->DNSInformation->SearchDomain = NULL;
	tds__GetDNSResponse->DNSInformation->__sizeDNSFromDHCP = 0;
	tds__GetDNSResponse->DNSInformation->DNSFromDHCP = NULL; 

	tds__GetDNSResponse->DNSInformation->__sizeDNSManual = 1;
	tds__GetDNSResponse->DNSInformation->DNSManual = (struct tt__IPAddress *)soap_malloc(soap,sizeof(struct tt__IPAddress));
	tds__GetDNSResponse->DNSInformation->DNSManual->Type = 0;
	tds__GetDNSResponse->DNSInformation->DNSManual->IPv4Address = (char *)soap_malloc(soap,sizeof(char) * IPv4_LEN);
	tds__GetDNSResponse->DNSInformation->DNSManual->IPv6Address = NULL; // add by lizh.
	strcpy(tds__GetDNSResponse->DNSInformation->DNSManual->IPv4Address,get_ipaddr());
	
	tds__GetDNSResponse->DNSInformation->Extension = NULL;
	tds__GetDNSResponse->DNSInformation->__anyAttribute = NULL;

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetDNS */
int __tds__SetDNS(struct soap *soap, struct _tds__SetDNS *tds__SetDNS, struct _tds__SetDNSResponse *tds__SetDNSResponse)
{
	INFO(stderr);

	save_configs("DNS",(void *)tds__SetDNS, TYPE_DNS);
	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetNTP */
int __tds__GetNTP(struct soap *soap, struct _tds__GetNTP *tds__GetNTP, struct _tds__GetNTPResponse *tds__GetNTPResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	tds__GetNTPResponse->NTPInformation = (struct tt__NTPInformation *)soap_malloc(soap,sizeof(struct tt__NTPInformation));
	tds__GetNTPResponse->NTPInformation->FromDHCP = FALSE;
	tds__GetNTPResponse->NTPInformation->__sizeNTPFromDHCP = 0;
	tds__GetNTPResponse->NTPInformation->NTPFromDHCP = NULL; 
	
	tds__GetNTPResponse->NTPInformation->__sizeNTPManual = 1;
	tds__GetNTPResponse->NTPInformation->NTPManual = (struct tt__NetworkHost *)soap_malloc(soap,sizeof(struct tt__NetworkHost ));
	tds__GetNTPResponse->NTPInformation->NTPManual->Type = 0;
	tds__GetNTPResponse->NTPInformation->NTPManual->IPv4Address = (char *)soap_malloc(soap,sizeof(char) * IPv4_LEN);
	tds__GetNTPResponse->NTPInformation->NTPManual->IPv6Address = NULL;//added by lizh.
	strcpy(tds__GetNTPResponse->NTPInformation->NTPManual->IPv4Address,get_ipaddr()); // ntp server ip address
	
	tds__GetNTPResponse->NTPInformation->NTPManual->DNSname = (char *)soap_malloc(soap,sizeof(char) * INFO_LEN);
	strcpy(tds__GetNTPResponse->NTPInformation->NTPManual->DNSname,"zm");
	tds__GetNTPResponse->NTPInformation->NTPManual->Extension = NULL; 
	tds__GetNTPResponse->NTPInformation->NTPManual->__anyAttribute = NULL;

	tds__GetNTPResponse->NTPInformation->Extension = NULL;
	tds__GetNTPResponse->NTPInformation->__anyAttribute = NULL;

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetNTP */
int __tds__SetNTP(struct soap *soap, struct _tds__SetNTP *tds__SetNTP, struct _tds__SetNTPResponse *tds__SetNTPResponse)
{
	INFO(stderr);
	
	save_configs("NTP",(void *)tds__SetNTP, TYPE_NTP);

	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDynamicDNS */
int __tds__GetDynamicDNS(struct soap *soap, struct _tds__GetDynamicDNS *tds__GetDynamicDNS, struct _tds__GetDynamicDNSResponse *tds__GetDynamicDNSResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);

	tds__GetDynamicDNSResponse->DynamicDNSInformation= (struct tt__DynamicDNSInformation *)soap_malloc(soap,sizeof(struct tt__DynamicDNSInformation ));
	tds__GetDynamicDNSResponse->DynamicDNSInformation->Type = tt__DynamicDNSType__NoUpdate;
	tds__GetDynamicDNSResponse->DynamicDNSInformation->Name = (char *)soap_malloc(soap,sizeof(char) * INFO_LEN);
	tds__GetDynamicDNSResponse->DynamicDNSInformation->TTL = NULL;

	tds__GetDynamicDNSResponse->DynamicDNSInformation->Extension = NULL;
	tds__GetDynamicDNSResponse->DynamicDNSInformation->__anyAttribute = NULL;
	
	strcpy(tds__GetDynamicDNSResponse->DynamicDNSInformation->Name,"zm_ddns");

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetDynamicDNS */
int __tds__SetDynamicDNS(struct soap *soap, struct _tds__SetDynamicDNS *tds__SetDynamicDNS, struct _tds__SetDynamicDNSResponse *tds__SetDynamicDNSResponse)
{
	INFO(stderr);
	
	save_configs("DynamicDNS",(void *)tds__SetDynamicDNS, TYPE_DDNS);
	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetNetworkInterfaces */
int __tds__GetNetworkInterfaces(struct soap *soap, struct _tds__GetNetworkInterfaces *tds__GetNetworkInterfaces, struct _tds__GetNetworkInterfacesResponse *tds__GetNetworkInterfacesResponse)
{	
	/* Return incomplete response with default data values */

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetNetworkInterfaces */
int __tds__SetNetworkInterfaces(struct soap *soap, struct _tds__SetNetworkInterfaces *tds__SetNetworkInterfaces, struct _tds__SetNetworkInterfacesResponse *tds__SetNetworkInterfacesResponse)
{	
	/* Return incomplete response with default data values */
	INFO(stderr);
	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetNetworkProtocols */
int __tds__GetNetworkProtocols(struct soap *soap, struct _tds__GetNetworkProtocols *tds__GetNetworkProtocols, struct _tds__GetNetworkProtocolsResponse *tds__GetNetworkProtocolsResponse)
{	
	/* Return incomplete response with default data values */
	

	return SOAP_OK;
}


/** Auto-test server operation __tds__SetNetworkProtocols */
int __tds__SetNetworkProtocols(struct soap *soap, struct _tds__SetNetworkProtocols *tds__SetNetworkProtocols, struct _tds__SetNetworkProtocolsResponse *tds__SetNetworkProtocolsResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetNetworkDefaultGateway */
int __tds__GetNetworkDefaultGateway(struct soap *soap, struct _tds__GetNetworkDefaultGateway *tds__GetNetworkDefaultGateway, struct _tds__GetNetworkDefaultGatewayResponse *tds__GetNetworkDefaultGatewayResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetNetworkDefaultGateway */
int __tds__SetNetworkDefaultGateway(struct soap *soap, struct _tds__SetNetworkDefaultGateway *tds__SetNetworkDefaultGateway, struct _tds__SetNetworkDefaultGatewayResponse *tds__SetNetworkDefaultGatewayResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetZeroConfiguration */
int __tds__GetZeroConfiguration(struct soap *soap, struct _tds__GetZeroConfiguration *tds__GetZeroConfiguration, struct _tds__GetZeroConfigurationResponse *tds__GetZeroConfigurationResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetZeroConfiguration */
int __tds__SetZeroConfiguration(struct soap *soap, struct _tds__SetZeroConfiguration *tds__SetZeroConfiguration, struct _tds__SetZeroConfigurationResponse *tds__SetZeroConfigurationResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetIPAddressFilter */
int __tds__GetIPAddressFilter(struct soap *soap, struct _tds__GetIPAddressFilter *tds__GetIPAddressFilter, struct _tds__GetIPAddressFilterResponse *tds__GetIPAddressFilterResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetIPAddressFilter */
int __tds__SetIPAddressFilter(struct soap *soap, struct _tds__SetIPAddressFilter *tds__SetIPAddressFilter, struct _tds__SetIPAddressFilterResponse *tds__SetIPAddressFilterResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__AddIPAddressFilter */
int __tds__AddIPAddressFilter(struct soap *soap, struct _tds__AddIPAddressFilter *tds__AddIPAddressFilter, struct _tds__AddIPAddressFilterResponse *tds__AddIPAddressFilterResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__RemoveIPAddressFilter */
int __tds__RemoveIPAddressFilter(struct soap *soap, struct _tds__RemoveIPAddressFilter *tds__RemoveIPAddressFilter, struct _tds__RemoveIPAddressFilterResponse *tds__RemoveIPAddressFilterResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetAccessPolicy */
int __tds__GetAccessPolicy(struct soap *soap, struct _tds__GetAccessPolicy *tds__GetAccessPolicy, struct _tds__GetAccessPolicyResponse *tds__GetAccessPolicyResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetAccessPolicy */
int __tds__SetAccessPolicy(struct soap *soap, struct _tds__SetAccessPolicy *tds__SetAccessPolicy, struct _tds__SetAccessPolicyResponse *tds__SetAccessPolicyResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__CreateCertificate */
int __tds__CreateCertificate(struct soap *soap, struct _tds__CreateCertificate *tds__CreateCertificate, struct _tds__CreateCertificateResponse *tds__CreateCertificateResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetCertificates */
int __tds__GetCertificates(struct soap *soap, struct _tds__GetCertificates *tds__GetCertificates, struct _tds__GetCertificatesResponse *tds__GetCertificatesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetCertificatesStatus */
int __tds__GetCertificatesStatus(struct soap *soap, struct _tds__GetCertificatesStatus *tds__GetCertificatesStatus, struct _tds__GetCertificatesStatusResponse *tds__GetCertificatesStatusResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetCertificatesStatus */
int __tds__SetCertificatesStatus(struct soap *soap, struct _tds__SetCertificatesStatus *tds__SetCertificatesStatus, struct _tds__SetCertificatesStatusResponse *tds__SetCertificatesStatusResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__DeleteCertificates */
int __tds__DeleteCertificates(struct soap *soap, struct _tds__DeleteCertificates *tds__DeleteCertificates, struct _tds__DeleteCertificatesResponse *tds__DeleteCertificatesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetPkcs10Request */
int __tds__GetPkcs10Request(struct soap *soap, struct _tds__GetPkcs10Request *tds__GetPkcs10Request, struct _tds__GetPkcs10RequestResponse *tds__GetPkcs10RequestResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__LoadCertificates */
int __tds__LoadCertificates(struct soap *soap, struct _tds__LoadCertificates *tds__LoadCertificates, struct _tds__LoadCertificatesResponse *tds__LoadCertificatesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetClientCertificateMode */
int __tds__GetClientCertificateMode(struct soap *soap, struct _tds__GetClientCertificateMode *tds__GetClientCertificateMode, struct _tds__GetClientCertificateModeResponse *tds__GetClientCertificateModeResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetClientCertificateMode */
int __tds__SetClientCertificateMode(struct soap *soap, struct _tds__SetClientCertificateMode *tds__SetClientCertificateMode, struct _tds__SetClientCertificateModeResponse *tds__SetClientCertificateModeResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetRelayOutputs */
int __tds__GetRelayOutputs(struct soap *soap, struct _tds__GetRelayOutputs *tds__GetRelayOutputs, struct _tds__GetRelayOutputsResponse *tds__GetRelayOutputsResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetRelayOutputSettings */
int __tds__SetRelayOutputSettings(struct soap *soap, struct _tds__SetRelayOutputSettings *tds__SetRelayOutputSettings, struct _tds__SetRelayOutputSettingsResponse *tds__SetRelayOutputSettingsResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetRelayOutputState */
int __tds__SetRelayOutputState(struct soap *soap, struct _tds__SetRelayOutputState *tds__SetRelayOutputState, struct _tds__SetRelayOutputStateResponse *tds__SetRelayOutputStateResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__SendAuxiliaryCommand */
int __tds__SendAuxiliaryCommand(struct soap *soap, struct _tds__SendAuxiliaryCommand *tds__SendAuxiliaryCommand, struct _tds__SendAuxiliaryCommandResponse *tds__SendAuxiliaryCommandResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetCACertificates */
int __tds__GetCACertificates(struct soap *soap, struct _tds__GetCACertificates *tds__GetCACertificates, struct _tds__GetCACertificatesResponse *tds__GetCACertificatesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__LoadCertificateWithPrivateKey */
int __tds__LoadCertificateWithPrivateKey(struct soap *soap, struct _tds__LoadCertificateWithPrivateKey *tds__LoadCertificateWithPrivateKey, struct _tds__LoadCertificateWithPrivateKeyResponse *tds__LoadCertificateWithPrivateKeyResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetCertificateInformation */
int __tds__GetCertificateInformation(struct soap *soap, struct _tds__GetCertificateInformation *tds__GetCertificateInformation, struct _tds__GetCertificateInformationResponse *tds__GetCertificateInformationResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__LoadCACertificates */
int __tds__LoadCACertificates(struct soap *soap, struct _tds__LoadCACertificates *tds__LoadCACertificates, struct _tds__LoadCACertificatesResponse *tds__LoadCACertificatesResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__CreateDot1XConfiguration */
int __tds__CreateDot1XConfiguration(struct soap *soap, struct _tds__CreateDot1XConfiguration *tds__CreateDot1XConfiguration, struct _tds__CreateDot1XConfigurationResponse *tds__CreateDot1XConfigurationResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__SetDot1XConfiguration */
int __tds__SetDot1XConfiguration(struct soap *soap, struct _tds__SetDot1XConfiguration *tds__SetDot1XConfiguration, struct _tds__SetDot1XConfigurationResponse *tds__SetDot1XConfigurationResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDot1XConfiguration */
int __tds__GetDot1XConfiguration(struct soap *soap, struct _tds__GetDot1XConfiguration *tds__GetDot1XConfiguration, struct _tds__GetDot1XConfigurationResponse *tds__GetDot1XConfigurationResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDot1XConfigurations */
int __tds__GetDot1XConfigurations(struct soap *soap, struct _tds__GetDot1XConfigurations *tds__GetDot1XConfigurations, struct _tds__GetDot1XConfigurationsResponse *tds__GetDot1XConfigurationsResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__DeleteDot1XConfiguration */
int __tds__DeleteDot1XConfiguration(struct soap *soap, struct _tds__DeleteDot1XConfiguration *tds__DeleteDot1XConfiguration, struct _tds__DeleteDot1XConfigurationResponse *tds__DeleteDot1XConfigurationResponse)
{	
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDot11Capabilities */
int __tds__GetDot11Capabilities(struct soap *soap, struct _tds__GetDot11Capabilities *tds__GetDot11Capabilities, struct _tds__GetDot11CapabilitiesResponse *tds__GetDot11CapabilitiesResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetDot11Status */
int __tds__GetDot11Status(struct soap *soap, struct _tds__GetDot11Status *tds__GetDot11Status, struct _tds__GetDot11StatusResponse *tds__GetDot11StatusResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__ScanAvailableDot11Networks */
int __tds__ScanAvailableDot11Networks(struct soap *soap, struct _tds__ScanAvailableDot11Networks *tds__ScanAvailableDot11Networks, struct _tds__ScanAvailableDot11NetworksResponse *tds__ScanAvailableDot11NetworksResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__GetSystemUris */
int __tds__GetSystemUris(struct soap *soap, struct _tds__GetSystemUris *tds__GetSystemUris, struct _tds__GetSystemUrisResponse *tds__GetSystemUrisResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__StartFirmwareUpgrade */
int __tds__StartFirmwareUpgrade(struct soap *soap, struct _tds__StartFirmwareUpgrade *tds__StartFirmwareUpgrade, struct _tds__StartFirmwareUpgradeResponse *tds__StartFirmwareUpgradeResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}


/** Auto-test server operation __tds__StartSystemRestore */
int __tds__StartSystemRestore(struct soap *soap, struct _tds__StartSystemRestore *tds__StartSystemRestore, struct _tds__StartSystemRestoreResponse *tds__StartSystemRestoreResponse)
{	
	/* Return incomplete response with default data values */
	return SOAP_OK;
}
